package top.yzhao.trackdatasystem.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.yzhao.trackdatasystem.dao.LogDao;
import top.yzhao.trackdatasystem.model.Log;
import top.yzhao.trackdatasystem.service.LogService;
import top.yzhao.trackdatasystem.utils.DateUtilsMy;
import top.yzhao.trackdatasystem.utils.IpUtilsMy;

import java.util.List;

/**
 * User: zhaoyang
 * Date: 2020/3/13
 * Time: 15:50
 * Description: No Description
 */
@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private LogDao logDao;

    @Override
    public List<Log> getLogList(String query, int currentPage, int pageSize) {
        List<Log> logList = logDao.getLogList(query,(currentPage-1)*pageSize,pageSize);
        return logList;
    }

    @Override
    public int getTotalLogList() {
        return logDao.getTotalLogList();
    }

    @Override
    public int addLog(Log log) {
        log.setOp_time(DateUtilsMy.getCurrentTiem());
        log.setIp_address(IpUtilsMy.getRemoteRequestIp());
        return logDao.addLog(log);
    }
}
